<template>
  <el-dialog
    class="orderRescind"
    title="退回案件"
    :visible.sync="isShow"
    center
    :close="cancel"
    :append-to-body='true'
  >
    <el-form
      ref="form"
      :rules="rules"
      :model="form"
      label-width="120px"
      label-position="top"
    >
      <el-form-item label="退回原因" prop="review">
        <el-input
          type="textarea"
          :rows="2"
          placeholder="请输入内容"
          v-model="form.review"
        >
        </el-input>
      </el-form-item>
    </el-form>

    <span slot="footer">
      <el-button size="mini" @click="cancel">取 消</el-button>
      <el-button type="success" size="mini" :loading="isSendBtnLoading" @click="submit"
        >提交</el-button
      >
    </span>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      isShow: false,
      orderdata: null,
      form: {
        review: "",
      },
      rules: {
        review: [{ required: true, message: "请输入退回原因", trigger: "blur" }],
      },
      isSendBtnLoading: false,
    };
  },
  methods: {
    show(row) {
      this.isShow = true;
      this.orderdata = row;
    },
    cancel() {
      this.isShow = false;
      this.$refs["form"].resetFields();
    },
    submit() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.submitPsot();
        } else {
          return false;
        }
      });
    },
    submitPsot() {
      let params = {
        return_review: this.form.review,
      };
      this.$axios
        .put(`api/order/${this.orderdata.id}/agency_return_order`, params)
        .then((res) => {
          if (res.data.code == 200) {
            this.$alert("案件退回成功！", "提示", {
              confirmButtonText: "确定",
              callback: (action) => {
                
              },
            });
            this.cancel()
            this.$emit('refresh')
          } else {
            this.$alert(res.data.message, "提示", {
              confirmButtonText: "确定",
              callback: (action) => {},
            });
          }
        });
    },
  },
};
</script>

<style lang="less">
.orderRescind {
  .el-dialog {
    width: 500px;
  }

  .el-select {
    width: 100%;
  }
}
</style>
